<template>
  <CommonPanel title="车辆告警事件">
    <div class="content-box1">
      <div class="content-box1_top">今日告警
        <span>{{total}}</span>
      </div>
      <div>
       <ScrollTable :columns="columns" :tableData="prjLists" >
      <template #default="{ prjLists }">
        <div
          @click="handleDetail(item)"
          class="scroll-row"
          v-for="item in prjLists"
          :key="item.id"
        >
          <div class="scroll-row__item prj-name">{{ item.name }}</div>
          <div class="scroll-row__item">{{ item.typeLabel }}</div>
          <div class="scroll-row__item">{{ item.given_amount }}</div>
          <!-- <div
            class="scroll-row__item"
            :class="col.className"
            v-for="col of columns"
            :key="col.prop"
          >
            {{ item[col.prop] }}
          </div> -->
        </div>
      </template>
    </ScrollTable>
      </div>
    </div>
  </CommonPanel>
</template>

<script setup>
import * as echarts from "echarts";
import { computed, ref, onMounted, watch, reactive } from "vue";
const props = defineProps({
  data: Object
});
const columns = [
  { label: "告警时间", prop: "crossTime" ,className: "prj-name"},
  { label: "区域", prop: "monitoringName" },
  { label: "告警类型", prop: "illegal" },
];
const prjLists = ref([])
const total = ref(1)

watch(() => props.data, (newData) => {
      if (newData) {
        prjLists.value= newData.car_vehicle_event?.map(item=>{
          item.illegal = ["超速",'逆行',"黑名单","违停"][item?.illegalType-1]
          return item
        })
        total.value= prjLists.value.length
      }
    });

</script>

<style lang="scss" scoped>
.content-box1 {
  height: 100%;
  display: flex;
  box-sizing: border-box;
  padding: 16px 6px;
  flex-direction: column;

  &_top {
    height: 30px;
    width: 100%;
    text-align: center;
    line-height: 30px;
    font-size: 20px;
    color: #9BA3AE;

    span {
      font-weight: 600;
      font-size: 24px;
      color: #65E3F8;
    }
  }
  }
</style>
